<?php
/**
 * Created by PhpStorm.
 * User: win7
 * Date: 2018/4/27
 * Time: 11:56
 */

namespace app\api\model;

class Banner extends BaseModel
{
    // 使用保护属性$hidden隐藏前端不需要的字段
    protected $hidden = ['id', 'update_time', 'delete_time'];
    // Banner模型关联BannerItem模型
    public function items() {
        return $this->hasMany('BannerItem', 'banner_id', 'id');
    }
    public static function getBannerByID($id) {
        $banner = self::with(['items', 'items.img'])->find($id);
        return $banner;
    }
}